"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const config_app = require("../../../config/app.js");
const utils_tools = require("../../../utils/tools.js");
const api_news_index = require("../../../api/news/index.js");
const api_police_index = require("../../../api/police/index.js");
const api_workGuide_index = require("../../../api/workGuide/index.js");
require("../../../utils/requestBase.js");
const stores_userInfo = require("../../../stores/userInfo.js");
if (!Array) {
  const _easycom_userOfTopLeft2 = common_vendor.resolveComponent("userOfTopLeft");
  const _easycom_up_text2 = common_vendor.resolveComponent("up-text");
  const _easycom_up_swiper2 = common_vendor.resolveComponent("up-swiper");
  const _easycom_up_avatar2 = common_vendor.resolveComponent("up-avatar");
  const _easycom_personalModule2 = common_vendor.resolveComponent("personalModule");
  const _easycom_up_tabs2 = common_vendor.resolveComponent("up-tabs");
  const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
  const _easycom_up_modal2 = common_vendor.resolveComponent("up-modal");
  const _easycom_up_gap2 = common_vendor.resolveComponent("up-gap");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_userOfTopLeft2 + _easycom_up_text2 + _easycom_up_swiper2 + _easycom_up_avatar2 + _easycom_personalModule2 + _easycom_up_tabs2 + _easycom_up_button2 + _easycom_up_modal2 + _easycom_up_gap2 + _easycom_up_toast2)();
}
const _easycom_userOfTopLeft = () => "../../../components/userOfTopLeft/userOfTopLeft.js";
const _easycom_up_text = () => "../../../node-modules/uview-plus/components/u-text/u-text.js";
const _easycom_up_swiper = () => "../../../node-modules/uview-plus/components/u-swiper/u-swiper.js";
const _easycom_up_avatar = () => "../../../node-modules/uview-plus/components/u-avatar/u-avatar.js";
const _easycom_personalModule = () => "../../../components/personalModule/personalModule.js";
const _easycom_up_tabs = () => "../../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
const _easycom_up_button = () => "../../../node-modules/uview-plus/components/u-button/u-button.js";
const _easycom_up_modal = () => "../../../node-modules/uview-plus/components/u-modal/u-modal.js";
const _easycom_up_gap = () => "../../../node-modules/uview-plus/components/u-gap/u-gap.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_userOfTopLeft + _easycom_up_text + _easycom_up_swiper + workGuideMenu + moduleOuterBox + menuWithBg + _easycom_up_avatar + _easycom_personalModule + _easycom_up_tabs + newsListItem + _easycom_up_button + _easycom_up_modal + _easycom_up_gap + _easycom_up_toast)();
}
const moduleOuterBox = () => "../../../components/moduleOuterBox/moduleOuterBox.js";
const workGuideMenu = () => "../../../components/workGuideMenu/workGuideMenu.js";
const menuWithBg = () => "../../../components/menuWithBg/menuWithBg.js";
const newsListItem = () => "../../../components/newsListItem/newsListItem.js";
const _sfc_defineComponent = common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    const userInfoStore = stores_userInfo.useUserInfoStore();
    const uToastRef = common_vendor.ref(null);
    const data = common_vendor.reactive({
      policeInfo: null,
      news: {
        queryParams: {
          pageNum: 1,
          pageSize: 5
        },
        current: 0,
        list: [],
        request: [
          api_news_index.listAntiFraud,
          api_news_index.listFireSafety,
          api_news_index.listPreventiveTip,
          api_news_index.regulationslistPage
        ]
      },
      bsznMenu: [],
      hdzqMenu: [
        {
          title: "办事咨询",
          bgColor: "yellow"
        },
        {
          title: "服务评价",
          bgColor: "tangerine"
        },
        {
          title: "举报投诉",
          bgColor: "azure"
        }
      ],
      showModal: false,
      isLogin: false,
      ccInfo: common_vendor.ref(null),
      //群众所属社区信息
      policePoiInfo: {
        lat: 29.828773,
        lnt: 106.439854,
        tel: "(023)68316055",
        communityName: "朝阳派出所",
        communitAddress: "重庆市北碚区朝阳街道静宁路23号"
      }
    });
    const {
      policeInfo,
      news,
      bsznMenu,
      hdzqMenu,
      showModal,
      isLogin,
      ccInfo,
      policePoiInfo
    } = common_vendor.toRefs(data);
    const current = common_vendor.ref(0);
    const swipers = common_vendor.reactive([
      "https://mscy.cqlandun.com:8088/static/crowd-banner1.png",
      "https://mscy.cqlandun.com:8088/static/crowd-banner2.png",
      "https://mscy.cqlandun.com:8088/static/crowd-banner3.png"
    ]);
    common_vendor.reactive(userInfoStore.crowdInfo);
    const userRegister = (e) => {
      showModal.value = false;
      utils_tools.onLogin(e, uToastRef);
    };
    const initWorkGuide = () => {
      api_workGuide_index.workGuideOfHOme({
        pageNum: 1,
        pageSize: 3,
        queryType: 1
      }).then((res) => {
        const { data: data2 } = res;
        data2.records = data2.records ?? [];
        if (data2.records.length) {
          bsznMenu.value = data2.records.map((item, index) => {
            item.icon = config_app.imgPrefix + item.logoUrl;
            item.title = item.itemName;
            if (index === 0) {
              item.bgOffset0 = "#fef9ec";
              item.bgOffset1 = "#fffcf7";
            }
            if (index === 1) {
              item.bgOffset0 = "#F6FFFD";
              item.bgOffset1 = "#F3FFFB";
            }
            if (index === 2) {
              item.bgOffset0 = "#ECF5FC";
              item.bgOffset1 = "#F4F8FB";
            }
            return item;
          });
        }
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const workGuideItemDeatil = (item) => {
      common_vendor.index.navigateTo({
        url: `/subPages/crowd/workGuide/detail?id=${item.id}`
      });
    };
    const onHdzqMenuItem = (item) => {
      if (userInfoStore.token && userInfoStore.openId) {
        if (item.title === "办事咨询") {
          common_vendor.index.navigateTo({
            url: "/subPages/crowd/serviceConsultation/addConsultation"
          });
        }
        if (item.title === "服务评价") {
          common_vendor.index.navigateTo({
            url: "/subPages/crowd/serviceEvaluation/addEvaluation"
          });
        }
        if (item.title === "举报投诉") {
          common_vendor.index.navigateTo({
            url: "/subPages/crowd/reportComplaint/addComplaint"
          });
        }
      } else {
        showModal.value = true;
      }
    };
    const navPosition = (poiInfo) => {
      common_vendor.index.openLocation({
        latitude: poiInfo.lat,
        longitude: poiInfo.lnt,
        scale: 18,
        name: poiInfo.communityName,
        address: poiInfo.communitAddress,
        success: function() {
          console.log("success");
        },
        fail: function(err) {
          console.log(err);
        }
      });
    };
    const getCommunityPolice = (communityId = userInfoStore.crowdInfo.communityId) => {
      api_police_index.selectIndexPoliceUser({ communityId }).then((res) => {
        const { data: data2 } = res;
        let arr = data2 ?? [];
        if (arr.length)
          policeInfo.value = arr[0];
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const initNews = () => {
      news.value.request[news.value.current](news.value.queryParams).then((res) => {
        const { data: data2 } = res;
        news.value.list = data2.records ?? [];
      }).catch((err) => {
        news.value.list = [];
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const onMoreNews = () => {
      let title = "";
      switch (news.value.current) {
        case 0:
          title = "反诈宣传";
          break;
        case 1:
          title = "消防安全";
          break;
        case 2:
          title = "防范提示";
          break;
        case 3:
          title = "政策规定";
          break;
      }
      common_vendor.index.navigateTo({
        url: `/subPages/crowd/news/index?newsTitle=${title}`
      });
    };
    const scanNewsDetail = (item) => {
      common_vendor.index.navigateTo({
        url: `/subPages/crowd/news/detail?newsId=${item.id}&newsType=${news.value.current}`
      });
    };
    common_vendor.onLoad(async () => {
      initWorkGuide();
      initNews();
      if (userInfoStore.token && userInfoStore.userInfo && userInfoStore.userInfo.registerStatus == 1) {
        isLogin.value = true;
        if (userInfoStore.userInfo.userType == 1)
          await utils_tools.getCrowdUserInfo(uToastRef);
      }
    });
    common_vendor.watch(
      userInfoStore,
      (newVal, oldVal) => {
        if (newVal && newVal.crowdInfo) {
          getCommunityPolice(newVal.crowdInfo.communityId);
        }
      },
      {
        immediate: true,
        deep: true
      }
    );
    common_vendor.onShareAppMessage((res) => {
      return {
        title: "码上朝阳",
        path: "/pages/crowd/home/index",
        imageUrl: "/static/logo.png",
        content: "我的码上朝阳小程序",
        mpId: "wxbaec7c3e7b23e9c4",
        type: 0
      };
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(isLogin)
      }, common_vendor.unref(isLogin) ? {
        b: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/crowd/mine/index")),
        c: common_vendor.p({
          userAvatar: common_vendor.unref(userInfoStore).userInfo.userAavatar,
          userName: common_vendor.unref(userInfoStore).userInfo.userName
        }),
        d: common_vendor.p({
          prefixIcon: "map-fill",
          iconStyle: {
            fontSize: "28rpx",
            color: "#fff"
          },
          text: common_vendor.unref(userInfoStore).crowdInfo ? common_vendor.unref(userInfoStore).crowdInfo.communityName : "",
          color: "#ffffff",
          size: "25rpx"
        })
      } : {
        e: common_vendor.o(userRegister),
        f: common_vendor.p({
          userAvatar: "",
          userName: "未登录",
          showMoreIcon: false
        })
      }, {
        g: common_vendor.f(common_vendor.unref(swipers), (item, index, i0) => {
          return {
            a: index,
            b: common_vendor.n(index === common_vendor.unref(current) && "indicator__dot--active")
          };
        }),
        h: common_vendor.o((e) => current.value = e.current),
        i: common_vendor.p({
          list: common_vendor.unref(swipers),
          circular: true,
          height: "360rpx",
          radius: "16rpx"
        }),
        j: common_vendor.o(workGuideItemDeatil),
        k: common_vendor.p({
          menuList: common_vendor.unref(bsznMenu)
        }),
        l: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/crowd/workGuide/home")),
        m: common_vendor.p({
          moduleTitle: "业务办理",
          moduleIcon: common_vendor.unref(common_assets.bsznIcon),
          showMore: true
        }),
        n: common_vendor.o(onHdzqMenuItem),
        o: common_vendor.p({
          menuList: common_vendor.unref(hdzqMenu)
        }),
        p: common_vendor.p({
          moduleTitle: "互动专区",
          moduleIcon: common_vendor.unref(common_assets.hdzqIcon)
        }),
        q: common_vendor.unref(isLogin) && common_vendor.unref(policeInfo)
      }, common_vendor.unref(isLogin) && common_vendor.unref(policeInfo) ? {
        r: common_vendor.p({
          src: common_vendor.unref(config_app.imgPrefix) + common_vendor.unref(policeInfo).avatar,
          shape: "circle",
          size: "50"
        }),
        s: common_vendor.t(common_vendor.unref(policeInfo).communityName + "民警"),
        t: common_vendor.p({
          suffixIcon: "arrow-right",
          iconStyle: {
            color: "#000",
            fontSize: "20rpx"
          },
          text: "更多",
          color: "#000000",
          size: "25rpx"
        }),
        v: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/crowd/policeStatus/index")),
        w: common_vendor.t(common_vendor.unref(policeInfo).userName),
        x: common_vendor.t(common_vendor.unref(policeInfo).badgeNumber),
        y: common_vendor.t(common_vendor.unref(policeInfo).phonenumber),
        z: common_vendor.o(($event) => common_vendor.unref(utils_tools.callPhone)(common_vendor.unref(policeInfo).phonenumber)),
        A: common_vendor.t(common_vendor.unref(policeInfo).communitAddress),
        B: common_vendor.unref(common_assets.locationIcon),
        C: common_vendor.o(($event) => navPosition(common_vendor.unref(policeInfo)))
      } : {
        D: common_vendor.p({
          src: common_vendor.unref(common_assets.chaoyangLogo),
          shape: "circle",
          size: "57"
        }),
        E: common_vendor.t(common_vendor.unref(policePoiInfo).communityName),
        F: common_vendor.t(common_vendor.unref(policePoiInfo).tel),
        G: common_vendor.o(($event) => common_vendor.unref(utils_tools.callPhone)(common_vendor.unref(policePoiInfo).tel)),
        H: common_vendor.t(common_vendor.unref(policePoiInfo).communitAddress),
        I: common_vendor.unref(common_assets.locationIcon),
        J: common_vendor.o(($event) => navPosition(common_vendor.unref(policePoiInfo)))
      }, {
        K: common_vendor.p({
          height: 222,
          leftWidth: 170,
          contentStyle: {
            padding: "24rpx"
          },
          showStatus: true,
          showGapLine: true,
          statusBgColor: common_vendor.unref(policeInfo) != null && common_vendor.unref(policeInfo).dutyStatus != 3 ? "#33A954" : "#BBBBBB",
          statusName: common_vendor.unref(policeInfo) != null ? common_vendor.unref(policeInfo).dutyStatus != 3 ? "在岗" : "" : ""
        }),
        L: common_vendor.p({
          suffixIcon: "arrow-right",
          iconStyle: {
            color: "#000",
            fontSize: "20rpx"
          },
          text: "更多",
          color: "#000000",
          size: "25rpx"
        }),
        M: common_vendor.o(onMoreNews),
        N: common_vendor.o((item, index) => {
          common_vendor.unref(news).current = index;
          initNews();
        }),
        O: common_vendor.p({
          list: [{
            name: "反诈宣传"
          }, {
            name: "消防安全"
          }, {
            name: "防范提示"
          }, {
            name: "政策规定"
          }],
          lineColor: "#0A8CFE",
          lineWidth: "70rpx",
          activeStyle: {
            color: "#0A8CFE",
            fontSize: "32rpx"
          },
          inactiveStyle: {
            color: "#000",
            fontSize: "32rpx"
          },
          current: common_vendor.unref(news).current,
          itemStyle: "height: 70rpx;width:110rpx"
        }),
        P: common_vendor.f(common_vendor.unref(news).list, (item, index, i0) => {
          return {
            a: "95c66bc6-14-" + i0,
            b: common_vendor.p({
              newsTitle: item.title,
              newsTime: item.createTime ? common_vendor.unref(common_vendor.dayjs)(item.createTime).format("YYYY-MM-DD") : "",
              newsImg: common_vendor.unref(config_app.imgPrefix) + item.imgUrl
            }),
            c: item.id,
            d: common_vendor.o(($event) => scanNewsDetail(item), item.id)
          };
        }),
        Q: common_vendor.o(($event) => showModal.value = false),
        R: common_vendor.p({
          type: "info",
          hairline: true,
          text: "取消"
        }),
        S: common_vendor.o(userRegister),
        T: common_vendor.p({
          type: "primary",
          hairline: true,
          text: "去登录",
          ["open-type"]: "getPhoneNumber"
        }),
        U: common_vendor.p({
          show: common_vendor.unref(showModal),
          title: "提示",
          content: "为保障您的账户安全，请先进行登录",
          contentTextAlign: "center"
        }),
        V: common_vendor.p({
          height: "16"
        }),
        W: common_vendor.sr(uToastRef, "95c66bc6-19", {
          "k": "uToastRef"
        })
      });
    };
  }
});
_sfc_defineComponent.__runtimeHooks = 2;
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_defineComponent, [["__scopeId", "data-v-95c66bc6"]]);
wx.createPage(MiniProgramPage);
